<?php
/**
 * 评价模型类
 * User: lxq
 * Date: 2018/4/20
 * Time: 11:32
 */
class commentModel extends Model{

    public function __construct()
    {
        parent::__construct('comment');
    }

    /**
     * 获取列表分页
     * @param array $condition
     * @param string $field
     * @param int $page
     * @param string $order
     * @return mixed
     */
    public function getCommentPage($condition = array(), $field = '*', $page = 0, $order = 'id desc'){
        return $this->field($field)->where($condition)->page($page)->order($order)->select();
    }

    /**
     * 获取一条记录的详细信息
     * @param array $condition
     * @param string $field
     * @return mixed
     */
    public function getCommentInfo($condition = array(), $field = '*')
    {
        return $this->field($field)->where($condition)->find();
    }

    /**
     * 插入一条记录
     * @param array $params
     * @return mixed
     */
    public function addComment($params)
    {
        return $this->insert($params);
    }

    /**
     * 更新记录
     * @param array $condition
     * @param array $params
     * @return mixed
     */
    public function updateComment($condition, $params)
    {
        return $this->where($condition)->update($params);
    }


    /**
     * 获取记录数组
     * @param array $condition
     * @param string $field
     * @param string $order
     * @return mixed
     */
    public function getCommentList($condition = array(), $field = '*', $order = 'order_id desc'){
        return $this->field($field)->where($condition)->order($order)->select();
    }

    /**
     * 取得评论条数数量
     * @param array $condition
     */
    public function getCommentCount($condition) {
        return $this->where($condition)->count();
    }
}